import os
import sys

from core.rest_client import RestClient
from common.read_data import data

BASE_PATH = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(BASE_PATH)

data_file_path = os.path.join(BASE_PATH, "config", "setting.ini")
api_root_url = data.load_ini(data_file_path)["host"]["api_root_url"]


class Group(RestClient):
    '''
    用户组的url定义类
    '''

    def __init__(self, api_root_url, **kwargs):
        super(Group, self).__init__(api_root_url, **kwargs)

    def list(self, **kwargs):
        '''
        获取所有的用户组
        '''
        return self.get("/api/group/list", **kwargs)


    def info(self,**kwargs):
        '''
        获取用户组信息
        '''
        return self.get("/api/group/info", **kwargs)

    def create(self, **kwargs):
        '''
        创建用户分组
        '''
        return self.post("/api/group/create", **kwargs)

    def modify(self, **kwargs):
        '''
        修改用户分组
        '''
        return self.post("/api/group/modify", **kwargs)


group = Group(api_root_url)